#ifndef TRACER_H_INCLUDED
#define TRACER_H_INCLUDED

#include "python.h"
#include "../utils/reporting.h"
#include "../utils/treefile.h"
#include "../utils/listfile.h"
#include "../utils/htable.h"
#include "../utils/swriter.h"


#define TRACER_ERRCODE_BASE              (21800)

#define CODEPOINT_TYPE_CODEOBJ     (1)
#define CODEPOINT_TYPE_CFUNC       (2)
#define CODEPOINT_TYPE_LOG         (3)

#define CODEPOINT_FLAGS_VARARGS    (1)
#define CODEPOINT_FLAGS_KWARGS     (2)


typedef struct _tracer_t {
	listfile_t    codepoints_list;
	listfile_t    values_list;
	htable_t      codepoints_table;
	treefile_t    trace_tree;
	swriter_t     serializer;
} tracer_t;


int tracer_init(tracer_t * self, const char * codepoints_filename,
		const char * values_filename, const char * tracetree_filename,
		int max_depth);
int tracer_fini(tracer_t * self);
int tracer_pyfunc_enter(tracer_t * self, PyCodeObject * codeobj, PyObject ** args, int argcount);
int tracer_cfunc_enter(tracer_t * self, PyCFunctionObject * cfunc);
int tracer_pyfunc_return(tracer_t * self, PyObject * retval);
int tracer_cfunc_return(tracer_t * self);
int tracer_function_raise(tracer_t * self, PyObject * excinfo);
int tracer_log(tracer_t * self, PyObject * fmtstring, PyObject * argstuple);



#endif
